using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class InfoPlane : MonoBehaviour
{
    public TMP_Text title;
    public TMP_Text diff;
    public TMP_Text scoreTx;
    public TMP_Text mxCombo;
    public Image FC;
    public Image rank;
    public Sprite[] rankSprites;

    public TMP_Text comP;
    public TMP_Text comGR;
    public TMP_Text comGO;
    public TMP_Text comB;
    public TMP_Text comM;

    void Start()
    {

        title.text = PlayerPrefs.GetString("BgmName", "");
        diff.text = PlayerPrefs.GetString("Diff", "easy");
        scoreTx.text = PlayerPrefs.GetString("Score", "0");
        mxCombo.text = PlayerPrefs.GetInt("MxCombo", 0).ToString("D4");

        if (PlayerPrefs.GetInt("IsFC", 0) == 1)
        {
            FC.gameObject.SetActive(true);
        }

        int score = int.Parse(scoreTx.text);

        if (score >= 8500000) //S
        {
            rank.sprite = rankSprites[0];
        }
        else if (score >= 8000000)//A
        {
            rank.sprite = rankSprites[1];
        }
        else if (score >= 7000000)//B
        {
            rank.sprite = rankSprites[2];
        }
        else if (score >= 6000000)//C
        {
            rank.sprite = rankSprites[3];
        }
        else //D
        {
            rank.sprite = rankSprites[4];
        }

        comP.text = PlayerPrefs.GetInt("comP", 0).ToString("D4");
        comGR.text = PlayerPrefs.GetInt("comGR", 0).ToString("D4");
        comGO.text = PlayerPrefs.GetInt("comGO", 0).ToString("D4");
        comB.text = PlayerPrefs.GetInt("comB", 0).ToString("D4");
        comM.text = PlayerPrefs.GetInt("comM", 0).ToString("D4");
    }
}
